package com.hx.portal.controller.hospital;

import com.alibaba.dubbo.config.annotation.Reference;
import com.hx.common.result.PageResult;
import com.hx.common.result.Result;
import com.hx.hospital.pojo.Departments;
import com.hx.hospital.service.DepartmentsService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/departments")
@Api(description = "详细科室相关接口")
public class DepartmentsController {

    @Reference
    private DepartmentsService departmentsService;

    @GetMapping("/findAll")
    public List<Departments> findAll(){
        return departmentsService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<Departments> findPage(int page, int size){
        return departmentsService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<Departments> findList(@RequestBody Map<String,Object> searchMap){
        return departmentsService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<Departments> findPage(@RequestBody Map<String,Object> searchMap,int page, int size){
        return  departmentsService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public Departments findById(Long id){
        return departmentsService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody Departments departments){
        departmentsService.add(departments);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody Departments departments){
        departmentsService.update(departments);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Long id){
        departmentsService.delete(id);
        return new Result();
    }

}
